<?php
/**
 * ZView
 *
 * Zend Frameworks View Component for TYPO3
 *
 * @package    ZView
 * @copyright  Copyright (c) Zephir AG, www.zephir.ch
 */

/** Abstract class for extension */
require_once 'Zend/View/Helper/Abstract.php';

/**
 * Helper to generate an "url" (using for the href attribute)
 *
 * @package ZView
 * @copyright  Copyright (c) Zephir AG, www.zephir.ch
 */
class Tx_Zview_Helper_T3extConf extends Zend_View_Helper_Abstract
{

	/**
	 * Retrieve an extConf value
	 *
	 * Return a value from extension configuration.
	 *
	 * @param string
	 * @return string
	 */
	public function t3extConf($fieldName)
	{
		$pi = $this->view->getPi();
		if(empty($pi) || (!$pi instanceof tslib_pibase)) {
			throw new Exception('Please set tslib_pibase using $view->setPi($this) in your plugin class.');
		}
		global $TYPO3_CONF_VARS;
		if(isset($TYPO3_CONF_VARS['EXT']['extConf'][$pi->extKey])) {
			$extConf = @unserialize($TYPO3_CONF_VARS['EXT']['extConf'][$pi->extKey]);
			if(array_key_exists($fieldName, $extConf)) {
				return $extConf[$fieldName];
			}
		}
		return null;
	}

}

if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/zview/helper/T3extConf.php']) {
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/zview/helper/T3extConf.php']);
}
